//
//  NSString+Extension.h
//  DaRen
//
//  Created by yuhaimingfk on 2019/9/2
//  Copyright © 2019 DR. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface NSString (Extension)
+(NSString *)getRandomStr;
+(NSDictionary *)readJson2DicWithFileName:(NSString *)fileName;
+ (NSString *)formatCount:(NSInteger)count;
/*
    给金额字符串添加分割标示，例：33，345，434.98
 */
+(NSString *)ResetAmount:(NSString *)Amount_str segmentation_index:(int)segmentation_index segmentation_str:(NSString *)segmentation_str;
/*
    根据当前语言国际化
 */
+(NSString *)LanguageInternationalizationCH:(NSString *)Chinese EN:(NSString *)English;
/**
 *  @brief  掉头反转字符串
 */
- (NSString *)StringReverse;
//编码反编码
-(NSString *)EncodingString;
-(NSString *)RemovingEncoding;

#pragma mark - string of size
- (CGSize)sizeWithFont:(UIFont *)font;
- (CGSize)sizeWithFont:(UIFont *)font andMaxW:(CGFloat)maxW;
/**
 根据文字计算宽度

 @param string 文字
 @param height 高度
 @param font 文字大小
 @return 返回的宽度
 */
+ (CGFloat)calculateRowWidth:(NSString *)string withHeight:(NSInteger)height font:(NSInteger)font;

#pragma mark - nil NULL "space"
+(BOOL)isNULL:(id)string;
#pragma md5
- (NSString *)MD5string;
/*
   把JSON格式的字符串转换成字典
 */
- (NSDictionary *)StringOfJsonConversionDictionary;
/**
 *  字符串添加图片
 */
-(NSMutableAttributedString *)insertImg:(UIImage *)Img atIndex:(NSInteger )index IMGrect:(CGRect )IMGrect;
/**
 *  不同颜色不同字体大小字符串
 */
-(NSMutableAttributedString *)setOtherColor:(UIColor *)Color font:(CGFloat)font forStr:(NSString *)forStr;
/*
    在文字上添加删除线（例如过去的价格）
 */
-(NSAttributedString *)AddRemoveLineOnStringRange:(NSRange )range lineWidth:(NSInteger )lineWidth;

- (BOOL)isChinese;
- (NSString *)pinyin;
- (NSString *)pinyinInitial;

- (BOOL)isEmail;
- (BOOL)isPhoneNumber;
- (BOOL)isDigit;
- (BOOL)isNumeric;
- (BOOL)isUrl;
- (BOOL)isMinLength:(NSUInteger)length;
- (BOOL)isMaxLength:(NSUInteger)length;
- (BOOL)isMinLength:(NSUInteger)min andMaxLength:(NSUInteger)max;
- (BOOL)isEmpty;


/// 手机号验证
/// @param mobileNum 要验证的手机号
+ (BOOL)validateContactNumber:(NSString *)mobileNum;


/// 清除url中反斜杠
/// @param urlString url字符串
+ (NSString *)clearBackslashWithUrlString:(NSString *)urlString;



- (CGSize)singleLineSizeWithAttributeText:(UIFont *)font;

- (CGSize)multiLineSizeWithAttributeText:(CGFloat)width font:(UIFont *)font;

- (CGSize)singleLineSizeWithText:(UIFont *)font;

- (NSURL *)urlScheme:(NSString *)scheme;

+ (NSString *)currentTime;



- (NSString *)md5;
+ (NSString *)md5_stringForString:(NSString *)string;
+ (NSString *)lowerMD5:(NSString *)inPutText;
+ (NSString *)upperMD5:(NSString *)inPutText;

#pragma mark - timeinterval转NSString
//传入 秒  得到  xx分钟xx秒
+(NSString *)getMMSSFromSS:(NSString *)totalTime;
/// 处理价格类浮点型数据精度问题
+ (NSString *)ys_reviseString:(NSString *)str;

@end
